<template>
  <div>
    <div style="padding: 5px 10px">

      <h3>评估报告信息:</h3>
      <div v-for="(item,index) in reportList" :key="index" style="margin-bottom: 20px">
        <report-detail :reportId="item.reportId" v-if="hasReportHis"></report-detail>
      </div>
      <!--  没有消息-->
      <div v-if="!hasReportHis" style="text-align: center;font-size: 18px;color: #3333;height: 160px;line-height: 160px;">
        暂无数据
      </div>
      <h3>中期评估报告历史信息:</h3>
      <process-handle-history :business-key="businessKey" :process-key="processKey"/>
    </div>
    <assign-history :visible="assignHisVisible"
                    :taskAssigneeHisList="taskAssigneeHisList"
                    @cancelAssignHis="cancelAssignHis"></assign-history>
  </div>
</template>

<script>
import reportDetail from "@/components/pim/report/detail";
import { getPmucReportDetail } from "@/api/pim/pim";
import {
  getReportHistory
} from "@/api/pim/pim";
import processHandleHistory from "@/components/activiti/history/processHandleHistory";

export default {
  name: "planningDetail",
  props: {
    id: String
  },
  components: {
    reportDetail,
    processHandleHistory
  },
  created () {
    this.getPmucReportDetail()
  },
  computed: {},
  data () {
    return {
      detaildata: {},
      historyData: {},
      reportId: '',
      hasReportHis:false,
      reportList:[],
      assignHisVisible:false,
      taskAssigneeHisList:[],
      businessKey: null,
      processKey: 'report_list'
    }
  },
  methods: {
    getPmucReportDetail () {
      getPmucReportDetail(this.id).then(response => {
        if(response.data.data.length == 0){
          this.hasReportHis = false;
        }else {
          this.hasReportHis = true;
        }

        if(response.data.data.length!=0){
          this.reportList = response.data.data;

          for (let i in response.data.data) {
            if (response.data.data[i].reportType == '2') {
              this.reportId = response.data.data[i].reportId;
            }
          }
        }
        if (this.reportId) {
          this.businessKey = this.reportId;
          this.getReportHistory()
        }
      })

    },
    getReportHistory () {
      getReportHistory(Object.assign({
        reportId: this.reportId,
      })).then(response => {
        this.historyData = response.data.data;
      })
    },
    taskAssigneeHisView(taskAssigneeHisList){
      this.assignHisVisible = true;
      this.taskAssigneeHisList = taskAssigneeHisList
    },
    cancelAssignHis(){
      this.assignHisVisible = false;
    }
  }
}
</script>

<style ang="scss" scoped>
</style>
